package com.cslg.ac.demo.dao.user;

import com.cslg.ac.demo.dao.user.po.UserAuthPO;
import org.apache.ibatis.annotations.*;

@Mapper
public interface UserAuthDAO {
    final String AUTH_TABLE = "e_user_auth";
    final String INSERT_FIELD = "id,userName,email_auth,phone_auth,idCard_auth";
    final String SELECT_FIELD = "id,userName,email_auth emailAuth,phone_auth phoneAuth,idCard_auth idCardAuth";

    @Insert({"insert into ",AUTH_TABLE,"(", INSERT_FIELD, ") values(#{id}, #{userName},#{emailAuth}, #{phoneAuth},#{idCardAuth})"})
    void insert(UserAuthPO userAuthPO);

    @Select({"select ",SELECT_FIELD," from ",AUTH_TABLE," where id = #{id}"})
    UserAuthPO selectById(@Param("id")int id);

    @Update({"update ",AUTH_TABLE," set userName = #{userName},email_auth = #{emailAuth},phone_auth = #{phoneAuth},idCard_auth = #{idCardAuth} where id = #{id}"})
    void update(UserAuthPO userAuthPO);

    @Select({"select ",SELECT_FIELD," from ",AUTH_TABLE," where userName = #{userName}"})
    UserAuthPO selectByName(@Param("userName")String userName);

}
